<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/website/common/base.jsp"%>

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>${webname }-登录</title>
<%@ include file="/website/common/common.jsp"%>
<link href="${webctx }/css/login.css" rel="stylesheet" type="text/css" />
</head>

<body>
<%@ include file="/website/common/top.jsp"%>
<%@ include file="/website/common/head.jsp"%>
<%@ include file="/website/common/menu.jsp"%>
<c:if test="${not empty requesturl}">
<input name="requesturl" type="hidden" value="${requesturl }">
</c:if>

<div id="wrap-main">
	<div class="login-box inner clearfix">
    	<div class="login-con">
        	<div class="login-left">
            	<div class="login-inf">  		
            	</div>
            	<div class="login-bbg">  		
            	</div>
            </div>
        	<div class="login-right">
            	<div class="login-hd">用户登录</div>
               	<div class="login-bd">
               		<div class="loginmsg"></div>
                    <div class="bd-item">
                    	<div class="item-con">
                            <span class="user-Ico"></span>
                            <input id="wsc-username" name="loginname" type="text" class="item-inp" placeholder="请输入手机号/用户名"/>
                        </div>                        
                    </div>
                    <div class="bd-item">
                    	<div class="item-con">
                            <span class="pass-Ico"></span>
                            <input id="wsc-password" name="pwd" type="password" class="item-inp" placeholder="密码" />
                        </div>                        
                    </div>
                    <div class="bd-item">
                        <div class="yzm-inp"><input name="checkcode" type="text"  placeholder="请输入验证码"/></div>
                        <div class="yzm-pic"><img src="" onclick="getcheckcodeimg()" id="checkcodeimg" style="width:110px;height:44px;cursor:pointer"/></div>
                    </div>
                    <div class="bd-item mt-30">
                    	<a href="javascript:tologin();" class="login-btn">登录</a>
                    </div>
                    <div class="bd-item-ft">
                        <span class="fl"><a href="javascript:showregisterpage();" class="col666">注册</a></span>
                        <span class="fr"><a href="${webctx }/user/findpwd.jsp" class="col666">忘记密码</a></span>
                     </div>
                </div>
            </div>
        </div>
    	
    </div>
</div>
<%@ include file="/website/common/foot.jsp"%>
</body>
</html>
<script>
$(function(){
	getcheckcodeimg();
	$(document).keydown(function(event){if (event.keyCode == 13){tologin();}});
})
function getcheckcodeimg(){
	$("#checkcodeimg").attr("src",server+"/validateimg?d="+new Date().getTime());
}
function tologin(){

	if($("[name='loginname']").val()==''){
		$(".loginmsg").text("请输入手机号/用户名！");
		$("[name='loginname']").focus();
	}else if($("[name='pwd']").val()==''){
		$(".loginmsg").text("请输入登录密码！");
		$("[name='pwd']").focus();
	}else{
        saveUserInfo();
		$(".login-btn").html('<img src="'+ctx+'/website/images/rr.gif">');
		$w.httpRequest({
			url:apiroot+"/user/login",
			data:{"loginname":$("[name='loginname']").val(),"pwd":$("[name='pwd']").val(),"checkcode":$("[name='checkcode']").val()},
			ok:function(ret){
				var user=ret.Data;
				$w.setLoginUser(user.userid,user.title,user.phone);
				var tourl="";
				if(sessionStorage.getItem("_curUrl_"))tourl=sessionStorage.getItem("_curUrl_");
				else if($("[name='requesturl']").length>0)tourl=$("[name='requesturl']").val()
				else tourl=ctx;
				if(tourl.indexOf("user/showlogin")!=-1)tourl=ctx+"/website/index.jsp";
				sessionStorage.removeItem("_curUrl_");
				var bl=true;
				try{
					if(sessionStorage.getItem("_newreg_")=='true'){
						bl=false;
						window.location.href=ctx+"/user/certification";
					}
					sessionStorage.removeItem("_newreg_");
				}catch(e){}

				//if(bl)window.location.href=tourl;

                if(bl)window.location.href= ctx+"/website/index.jsp";
			},fail:function(ret){
				$(".loginmsg").text(ret.MsgDesc);
				$(".login-btn").html('登录');
				return false;
			}
		})
	}
}

</script>